package com.lyf.baoxian.utils;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

/**
 * Created by 刘亚飞 on 2016/11/30.
 * 获取包管理的工具
 */

public class PackageInfoUtils {
    public static String getPackageVersion(Context context){
        try {
            //包的信息
            PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(),0);
            //版本号
            String version = packageInfo.versionName;
            return version;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
            return "解析版本号失败";
        }

    }
}
